Non-generic Stack can store Any type of object like Integer, String, Date…etc
Generic Stack can store only specify the ClassName.
Stack Class
In stack, elements are stored and accessed in Last In First Out manner. That is, elements are added to the top of the stack and removed from the top of the stack.
Stack Methods
void push(value)
To add an element to the top of the stack.
void pop( )
To remove an element from the top of the stack.
Object peek( )
The peek() method returns an object from the top of the stack.
int search(value )
To search an element in the stack, we use the search() method.
It returns the position of the element from the top of the stack.